<?php
namespace api\modules\v1\controllers;

use api\modules\v1\models\gift\Gift;
use api\modules\v1\models\gift\GiftCategory;
use api\modules\v1\models\gift\GiftLog;
use yii\filters\auth\HttpHeaderAuth;
use yii\helpers\ArrayHelper;
use Yii;

/**
 * Default controller for the `v1` module
 */
class GiftController extends DefaultController
{

    public $modelClass = 'api\modules\v1\models\imFriend\ImFriend';

    public function behaviors()
    {
        return ArrayHelper::merge(parent::behaviors(), [
            'authenticator' => [
                'class' => HttpHeaderAuth::className(),    //head头部验证
                'header' => 'access-token',
                'optional' => [                     //需要过滤掉不用token参数的方法

                ]
            ]
        ]);
    }

    // 礼物分类
    public function actionCategory() {
        if (Yii::$app->request->isGet) {
            return (new GiftCategory())->getMapForSelect();
        }
    }


    // 礼物列表
    public function actionList()
    {
        if (Yii::$app->request->isGet) {
            return (new Gift())->getList();
        }
    }


    // 送礼物
    public function actionSend()
    {
        if (Yii::$app->request->isPost) {
            return (new Gift())->sendGift();
        }
    }


    // 收到的礼物
    public function actionReceiveList()
    {
        if (Yii::$app->request->isGet) {
            return (new GiftLog())->getList();
        }
    }






}
